package com.fingersoft.sso;

import android.app.Activity;
import android.text.TextUtils;

import com.fingersoft.feature.login.LoginActivity;
import com.fingersoft.feature.userinfo.model.User;
import com.fingersoft.im.utils.AppUtils;

import java.util.Hashtable;

/**
 * Created by liubinbin on 12/01/2017.
 */

public class MySSOProvider extends SSOProvider {
    @Override
    public Hashtable<String, String> getUserInfo() {
        User user = AppUtils.getUser();
        if (TextUtils.isEmpty(user.getUserId()) || TextUtils.isEmpty(AppUtils.getTokenInfo().getUserToken())) {
            return new Hashtable<>();
        }
        Hashtable<String, String> userInfo = new Hashtable<>();
        userInfo.put("userId", user.getUserId());
        userInfo.put("userName", user.getUserName());
        userInfo.put("realName", user.getRealName());
        userInfo.put("empLivingPhoto", user.getEmpLivingPhoto());
        return userInfo;
    }

    @Override
    public String getUserToken() {
        return AppUtils.getTokenInfo().getUserToken();
    }

    /**
     * @return 用户是否登陆
     */
    @Override
    public boolean isLogin() {
        return AppUtils.isLogged();
    }

    @Override
    public void gotoLogin(Activity activity) {
        LoginActivity.start(activity, true);
    }
}
